
import random

class Person:

    name: str
    age: int
    height: float
    weight: float

    # 构造函数
    def __init__(self, name: str, age: int, height: float, weight: float, sex: str = "Unknown"):
        self.name = name
        self.age = age
        self.height = height
        self.weight = weight
        self.sex = sex # 公有属性
        self.__card_id = random.randint(10000, 20000)  # 私有属性

    def __str__(self):
        return f"Person(card_id={self.__card_id}, name={self.name}, age={self.age}, height={self.height}, weight={self.weight}, sex={self.sex})"
    
    def increase_age(self, years: int = 1):
        if years < 0:
            raise ValueError("Years cannot be negative")
        self.age += years

    def set_height_weight(self, height: float, weight: float):
        if height <= 0 or weight <= 0:
            raise ValueError("Height and weight must be positive values")
        self.height = height
        self.weight = weight

    # 私有方法
    def __clean__(self):
        print(f"Cleaning up resources for {self.name}")

    # 公有方法
    def rename(self, new_name: str):
        if not new_name:
            raise ValueError("Name cannot be empty")
        self.name = new_name
        self.__clean__()    

    # 方法属性化
    @property
    def reset(self):
        self.name = None
        self.age = None
        self.height = None
        self.weight = None
        self.sex = None

    # 类方法
    @classmethod
    def print_self(cls):
        print(f'类方法：{cls}')

    # 静态方法
    @staticmethod
    def print_static():
        print('调用了静态方法')

    # 析构函数
    def __del__(self):
        print(f"Person {self.name} is being deleted")





person1 = Person(name="Alice", age=18, height=1.65, weight=62.4, sex='male')
print(person1)
person1.increase_age(5)
person1.set_height_weight(1.70, 70.0)
person1.rename("Bob")
print(person1)

person2 = Person(name="Rose", age=17, height=1.67, weight=61.8, sex='female')
print(person2)
person2.increase_age(4)
person2.set_height_weight(1.72, 63.2)
person2.rename("Cherry")
print(person2)

person1.reset
print(person1)
Person.print_self()
Person.print_static()